package dao

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"time"
)

type Reservation struct {
	Id              int64     `json:"id" gorm:"column:id;comment:自增id"`
	SiteId          string    `json:"site_id" gorm:"column:site_id;comment:场地id"`
	SiteName        string    `json:"site_name" gorm:"column:site_name;comment:场地名称"`
	Title           string    `json:"title" gorm:"column:title;comment:活动名称"`
	Corporate       string    `json:"corporate" gorm:"column:corporate;comment:单位名称"`
	BeginTime       string    `json:"begin_time" gorm:"column:begin_time;comment:开始时间"`
	EndTime         string    `json:"end_time" gorm:"column:end_time;comment:结束时间"`
	Contact         string    `json:"contact" gorm:"column:contact;comment:联系人"`
	Phone           string    `json:"phone" gorm:"column:phone;comment:联系电话"`
	PeopleNum       string    `json:"people_num" gorm:"column:people_num;comment:活动人数"`
	Options         []byte    `json:"options" gorm:"column:options;comment:选项"`
	Remark          string    `json:"remark" gorm:"column:remark;comment:备注"`
	MeetingStatus   uint8     `json:"meeting_status" gorm:"column:meeting_status;comment:是否需要会务筹备 0不需要 1需要"`
	MeetingMark     string    `json:"meeting_mark" gorm:"column:meeting_mark;comment:会务筹备备注"`
	ExplainStatus   uint8     `json:"explain_status" gorm:"column:explain_status;comment:是否需要专业讲解 0不需要 1需要"`
	ExplainMark     string    `json:"explain_mark" gorm:"column:explain_mark;comment:专业讲解备注"`
	CareStatus      uint8     `json:"care_status" gorm:"column:care_status;comment:是否需要特别照顾 0 不需要 1需要"`
	AuditStatus     uint8     `json:"audit_status" gorm:"column:audit_status;comment:审核状态 0 审核中 1 审核通过 2 审核拒绝"`
	AuditRemark     string    `json:"audit_remark" gorm:"column:audit_remark;comment:审核备注"`
	DeleteRemark    string    `json:"delete_remark" gorm:"column:delete_remark;comment:删除备注"`
	CancelRemark    string    `json:"cancel_remark" gorm:"column:cancel_remark;comment:取消备注"`
	Star            uint8     `json:"star" gorm:"column:star;comment:评价星级"`
	Comment         string    `json:"comments" gorm:"column:comments;comment:评价"`
	CheckStatus     uint8     `json:"check_status" gorm:"column:check_status;comment:打卡状态"`
	IsManagerDelete uint8     `json:"is_manager_delete" gorm:"column:is_manager_delete;comment:是否是管理员删除"`
	CareMark        string    `json:"care_mark" gorm:"column:care_mark;comment:特殊照顾备注"`
	CreatedBy       string    `json:"created_by" gorm:"column:created_by;comment:创建人"`
	Status          uint8     `json:"status" gorm:"column:status;comment:状态"`
	IsDelete        uint8     `json:"is_delete" gorm:"column:is_delete;comment:1已删除"`
	UpdatedAt       time.Time `json:"update_at" gorm:"column:update_at;comment:更新时间"`
	CreatedAt       time.Time `json:"create_at" gorm:"column:create_at;comment:创建时间"`
}

func (f *Reservation) TableName() string {
	return "reservation"
}

// InitData 初始化reservation表
func (f *Reservation) InitData(tx *gorm.DB) error {
	return tx.AutoMigrate(f)
}

// Save 保存
func (f *Reservation) Save(c *gin.Context, tx *gorm.DB) error {
	if err := tx.WithContext(c).Save(f).Error; err != nil {
		return err
	}
	return nil
}
